/*
 * RandomTransitionsSettingsWindow.java
 *
 * Created on 12 czerwiec 2007, 08:23
 */

package edu.uj.petri.gui;

import java.util.ResourceBundle;
import javax.swing.SpinnerNumberModel;

/**
 *
 * @author  Tyggrysio
 */
public class RandomTransitionsSettingsWindow extends javax.swing.JDialog {
    
    private static final long serialVersionUID = 6774878543658743601L;
    
    /** Creates new form RandomTransitionsSettingsWindow */
    public RandomTransitionsSettingsWindow(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();
        
        this.numberSpinner.setModel(new SpinnerNumberModel(0, 0, 200, 1));
        this.delaySpinner.setModel(new SpinnerNumberModel(0, 0, 200, 1));
        
        this.setLocationRelativeTo(parent);
    }
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
    private void initComponents() {
        java.awt.GridBagConstraints gridBagConstraints;

        numberLabel = new javax.swing.JLabel();
        delayLabel = new javax.swing.JLabel();
        okButton = new javax.swing.JButton();
        numberSpinner = new javax.swing.JSpinner();
        delaySpinner = new javax.swing.JSpinner();

        getContentPane().setLayout(new java.awt.GridBagLayout());

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle(ResourceBundle.getBundle("edu/uj/petri/messages").getString("Random_Transitions_Firing")); // NOI18N
        numberLabel.setText(ResourceBundle.getBundle("edu/uj/petri/messages").getString("Number_of_transitions:")); // NOI18N
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.gridwidth = 2;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.insets = new java.awt.Insets(5, 10, 3, 10);
        getContentPane().add(numberLabel, gridBagConstraints);

        delayLabel.setText(ResourceBundle.getBundle("edu/uj/petri/messages").getString("Delay_[s]:")); // NOI18N
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 3;
        gridBagConstraints.gridwidth = 2;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.insets = new java.awt.Insets(2, 10, 3, 10);
        getContentPane().add(delayLabel, gridBagConstraints);

        okButton.setText("OK");
        okButton.setMaximumSize(new java.awt.Dimension(60, 23));
        okButton.setMinimumSize(new java.awt.Dimension(60, 23));
        okButton.setPreferredSize(new java.awt.Dimension(60, 23));
        okButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                okButtonActionPerformed(evt);
            }
        });

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 5;
        gridBagConstraints.insets = new java.awt.Insets(0, 0, 10, 10);
        getContentPane().add(okButton, gridBagConstraints);

        numberSpinner.setFont(new java.awt.Font("Courier", 0, 10));
        numberSpinner.setMaximumSize(new java.awt.Dimension(35, 18));
        numberSpinner.setMinimumSize(new java.awt.Dimension(35, 18));
        numberSpinner.setPreferredSize(new java.awt.Dimension(35, 18));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 2;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.insets = new java.awt.Insets(2, 10, 6, 0);
        getContentPane().add(numberSpinner, gridBagConstraints);

        delaySpinner.setFont(new java.awt.Font("Courier", 0, 10));
        delaySpinner.setMaximumSize(new java.awt.Dimension(35, 18));
        delaySpinner.setMinimumSize(new java.awt.Dimension(35, 18));
        delaySpinner.setPreferredSize(new java.awt.Dimension(35, 18));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 4;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.insets = new java.awt.Insets(2, 10, 5, 0);
        getContentPane().add(delaySpinner, gridBagConstraints);

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void okButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okButtonActionPerformed
        this.dispose();
    }//GEN-LAST:event_okButtonActionPerformed

    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel delayLabel;
    private javax.swing.JSpinner delaySpinner;
    private javax.swing.JLabel numberLabel;
    private javax.swing.JSpinner numberSpinner;
    private javax.swing.JButton okButton;
    // End of variables declaration//GEN-END:variables
 
    public int getNumberOfTransitions() {
        return Integer.parseInt(this.numberSpinner.getValue().toString());
    }
    
    public int getDelay() {
        return Integer.parseInt(this.delaySpinner.getValue().toString());
    }
}
